import '../entity/entities/lf_user_entity.dart';
import '../service/manager/lf_user_cache_manager.dart';

class UserRelationEvent {
  final String uid;
  final UserRelationType type;
  LfUserEntity? userEntity;
  bool? fromSpark;

  UserRelationEvent(
      {required this.uid,
      required this.type,
      this.userEntity,
      this.fromSpark}) {
    var cache = LfUserCacheManager().getCacheUser(key: uid);
    if (cache != null) {
      if (type == UserRelationType.wink) {
        cache.winked = 1;
        LfUserCacheManager().setCacheUser(key: uid, user: cache);
      } else if (type == UserRelationType.like) {
        cache.liked = 1;
        LfUserCacheManager().setCacheUser(key: uid, user: cache);
      } else if (type == UserRelationType.unlike) {
        cache.liked = 0;
        LfUserCacheManager().setCacheUser(key: uid, user: cache);
      } else if (type == UserRelationType.requestPrivate) {
        cache.privateAlbumStatus = 2;
        LfUserCacheManager().setCacheUser(key: uid, user: cache);
      } else if (type == UserRelationType.requestAccept) {
        cache.privateAlbumStatus = 1;
        LfUserCacheManager().setCacheUser(key: uid, user: cache);
      }
    }
  }
}

enum UserRelationType {
  block,
  unblock,
  like,
  wink,
  unlike,
  requestPrivate, //请求他人相册
  requestAccept, //同意他人申请查看自己的相册
}
